﻿using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KPIS.GERP.GFMS.APP.App_Code
{
    public class ConfiguratorPanel750 : Panel, IPostBackDataHandler
    {
        protected override void RenderContents(HtmlTextWriter writer)
        {
            writer.Write(string.Format(
                @"<div class=""moduleDivSlim"">
	            <div class=""moduleDivBottom"">
				<a class=""moduleDivSlimCollapsible"" href=""javascript:slideConfig('{0}', '{1}');"" onfocus=""blur()"">
                    <span class=""configTitle"">{3}</span>
					<span class=""configLine750""></span>
					<span class=""configButton toggle{2}""></span>
                </a>
                <div class=""moduleDivSlimContent"" style=""display:{4}"">",
                UniqueID,
                Expanded ? "Up" : "Down",
                Expanded ? "Up" : "Down",
                Title,
                Expanded ? "" : "none")
                );

            base.RenderContents(writer);

            writer.Write(string.Format(@"<input type=""hidden"" name=""{0}"" value=""{1}"" /></div></div></div>",
                UniqueID,
                Expanded)
                );
        }

        [DefaultValue("Configure this example")]
        public string Title
        {
            get { return (string)(ViewState["Title"] ?? "Configure this example"); }
            set { ViewState["Title"] = value; }
        }

        [DefaultValue(false)]
        public bool Expanded
        {
            get { return (bool)(ViewState["Expanded"] ?? false); }
            set { ViewState["Expanded"] = value; }
        }

        public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            if (!string.IsNullOrEmpty(postCollection[postDataKey]))
            {
                Expanded = Convert.ToBoolean(postCollection[postDataKey]);
            }
            return true;
        }

        public void RaisePostDataChangedEvent()
        {
        }
    }
}